import { IsNumber, IsString, IsOptional, MinLength, MaxLength, IsBoolean } from 'class-validator';
import mongoose from 'mongoose';


export class CreateDicDto {
    @IsString({ message: '字典项类型必须是字符串' })
    @MinLength(2, { message: '字典项类型长度不能小于2个字符' })
    @MaxLength(50)
    type!: string;

    @IsString({ message: '字典项标签必须是字符串' })
    @MinLength(2, { message: '字典项标签长度不能小于2个字符' })
    @MaxLength(50)
    label!: string;

    @IsOptional()
    value: any;

    @IsNumber({}, { message: '字典项排序必须是数字' })
    sort?: number;


    @IsOptional()
    @IsBoolean({ message: '字典项是否激活必须是布尔值' })
    isActive?: boolean;

    @IsOptional()
    @IsBoolean({ message: '字典项是否默认必须是布尔值' })
    isDefault?: boolean;

    @IsOptional()
    @IsString({ message: '字典项备注必须是字符串' })
    @MinLength(2, { message: '字典项备注长度不能小于2个字符' })
    @MaxLength(200)
    remark?: string;
    @IsOptional()
    @IsString({ message: '创建人必须是字符串' })
    createdBy!: mongoose.Schema.Types.ObjectId;
}


export class UpdateDicDto {
    @IsString({ message: '字典项类型必须是字符串' })
    @MinLength(2, { message: '字典项类型长度不能小于2个字符' })
    @MaxLength(50)
    type!: string;

    @IsString({ message: '字典项标签必须是字符串' })
    @MinLength(2, { message: '字典项标签长度不能小于2个字符' })
    @MaxLength(50)
    label!: string;

    @IsOptional()
    value: any;

    @IsNumber({}, { message: '字典项排序必须是数字' })
    sort?: number;


    @IsOptional()
    @IsBoolean({ message: '字典项是否激活必须是布尔值' })
    isActive?: boolean;

    @IsOptional()
    @IsBoolean({ message: '字典项是否默认必须是布尔值' })
    isDefault?: boolean;

    @IsOptional()
    @IsString({ message: '字典项备注必须是字符串' })
    @MinLength(2, { message: '字典项备注长度不能小于2个字符' })
    @MaxLength(200)
    remark?: string;


    @IsOptional()
    @IsString({ message: '更新人必须是字符串' })
    updatedBy!: mongoose.Schema.Types.ObjectId;


}
